﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RanchBuddy.Core.DataAccess.Impl;
using RanchBuddy.Core.Domain;
using RanchBuddy.Core.Domain.Impl;
using StructureMap;

namespace RanchBuddy.Core.Services.Impl
{
    [Pluggable("Default")]
    public class HelpMessageService : IHelpMessageService
    {
        public static string GetHelpMessageBodyByID(Int32 HelpMessageID)
        {
            string result = "";
            string cacheKey = "HelpMessageRepository_GetHelpMessageBodyByID_" + HelpMessageID;
            if (ObjectFactory.GetInstance<ICache>().Exists(cacheKey))
            {
                result = ObjectFactory.GetInstance<ICache>().Get(cacheKey) as string;
            }
            else
            {
                result = HelpMessageRepository.GetHelpMessageBodyByID(HelpMessageID);
                if (!string.IsNullOrEmpty(result))
                {
                    ObjectFactory.GetInstance<ICache>().Set(cacheKey, result);
                }
            }
            return result;
        }

        public static HelpMessage GetHelpMessageByID(Int32 HelpMessageID)
        {
            string cacheKey = "HelpMessageRepository_GetHelpMessageByID_" + HelpMessageID;
            HelpMessage result = null;
            if (ObjectFactory.GetInstance<ICache>().Exists(cacheKey))
            {
                result = ObjectFactory.GetInstance<ICache>().Get(cacheKey) as HelpMessage;
            }
            else
            {
                result = HelpMessageRepository.GetHelpMessageByID(HelpMessageID);
                ObjectFactory.GetInstance<ICache>().Set(cacheKey, result);
            }
            return result;
        }
    }
}
